package com.seleninum.Junit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.chrome.ChromeDriver;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.util.List;



public class App extends TestCase{
	private WebDriver driver;
	private Navigation navigation;

    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public App( String testName )
    {
        super( testName );
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( App.class );
    }

    public void setUp() throws Exception {
		//System.setProperty("webdriver.chrome.driver", "C:/Users/chen/AppData/Local/Google/Chrome/Application/chrome.exe");
	
		System.setProperty("webdriver.chrome.driver", "C:/Users/chen/AppData/Local/Google/Chrome/Application/chromedriver.exe");
    }
	

    public void tearDown() throws Exception {
    }


    //状态覆盖-路径
    public void testNavagtion1() throws InterruptedException {
        boolean rs=true;
     	try {
     		System.out.println("测试：状态覆盖");
			System.out.println("测试打开布尔表达式可视化系统");
			driver = new ChromeDriver();
			//driver.get("http://www.baidu.com");
			driver.get("http://2084w1u146.imwork.net:20890/");
			Thread.sleep(1000);
			
     		System.out.println("打开成功");
     		
	    	
       		WebElement elementTabs = driver.findElement(By.id("tabs"));
    		List<WebElement> tabs = elementTabs.findElements(By.className("r-tab"));
    		WebElement elementFaultDiagnose= tabs.get(0);
    		WebElement elementScene = tabs.get(1);
    		WebElement elementConfig = tabs.get(2);
    		
    		System.out.println("测试点击“设置”标签");
    		elementConfig.click();
    		Thread.sleep(1000);
    		
    		System.out.println("测试点击“场景”标签");
    		elementScene.click();
    		Thread.sleep(1000);
 
     		System.out.println("测试点击“层次关系”标签");
	    	WebElement searchButton = driver.findElement(By.className("top"))
	    			.findElement(By.tagName("a"));
	    	searchButton.click(); 
    	
    	} catch(Exception e) {
    		System.out.println("测试失败");
    		rs = false;
    	}
		driver.quit();
		System.out.println("测试成功");
    	assertTrue(rs);
    }
    
    //事件覆盖-路径
    public void testNavagtion2() throws InterruptedException {
        boolean rs=true;
     	try {
     		System.out.println("测试：事件覆盖");
			System.out.println("测试打开布尔表达式可视化系统");
			driver = new ChromeDriver();
			driver.get("http://2084w1u146.imwork.net:20890/");
//	 	Thread.sleep(3000);
        //getTitle()获取当前页面title的值    

//        System.out.println("当前打开页面的标题是： "+ driver.getTitle());   
//        String html = driver.getPageSource();    
		//navigation = driver.navigate();
    	//navigation.to("https://www.baidu.com");

//    	WebElement searchInput = driver.findElement(By.id("expressInput"));
//    	searchInput.sendKeys("ab+cd");
			
     		System.out.println("打开成功");
     		System.out.println("测试点击“层次关系”标签");
	    	WebElement searchButton = driver.findElement(By.className("top"))
	    			.findElement(By.tagName("a"));
	    	searchButton.click(); 
	    	Thread.sleep(1000);
	    	
	    	System.out.println("测试点击“可视化系统”标签");
	    	WebElement searchButton1 = driver.findElement(By.className("top"))
	    			.findElement(By.tagName("a"));
	    	searchButton1.click(); 
	    	Thread.sleep(1000);
 
	    	
       		WebElement elementTabs = driver.findElement(By.id("tabs"));
    		List<WebElement> tabs = elementTabs.findElements(By.className("r-tab"));
    		WebElement elementFaultDiagnose= tabs.get(0);
    		WebElement elementScene = tabs.get(1);
    		WebElement elementConfig = tabs.get(2);
    
    		System.out.println("测试点击“场景”标签");
    		elementScene.click();
    		Thread.sleep(1000);
    		System.out.println("测试点击“设置”标签");
    		elementConfig.click();
    		Thread.sleep(1000);
    		System.out.println("测试点击“缺陷诊断”标签");
    		elementFaultDiagnose.click();
    		Thread.sleep(1000);
    	
    	} catch(Exception e) {
    		System.out.println("测试失败");
    		rs = false;
    	}
		driver.quit();
		System.out.println("测试成功");
    	assertTrue(rs);
    }
   
    //状态事件组合-路径1
    public void testNavagtion3() throws InterruptedException {
        boolean rs=true;
     	try {
     		System.out.println("测试：状态事件组合路径1");
			System.out.println("测试打开布尔表达式可视化系统");
			driver = new ChromeDriver();
			driver.get("http://2084w1u146.imwork.net:20890/");
			
     		System.out.println("打开成功");
			WebElement elementTabs = driver.findElement(By.id("tabs"));
    		List<WebElement> tabs = elementTabs.findElements(By.className("r-tab"));
    		WebElement elementFaultDiagnose= tabs.get(0);
    		WebElement elementScene = tabs.get(1);
    		WebElement elementConfig = tabs.get(2);

    		System.out.println("测试点击“设置”标签");
    		elementConfig.click();
    		Thread.sleep(1000);
    		System.out.println("测试点击“场景”标签");
    		elementScene.click();
    		Thread.sleep(1000);
    		
    		System.out.println("测试点击“缺陷诊断”标签");
    		elementFaultDiagnose.click();
    		Thread.sleep(1000);
    		
    		System.out.println("测试点击“场景”标签");
    		elementScene.click();
    		Thread.sleep(1000);
    		
    		System.out.println("测试点击“设置”标签");
    		elementConfig.click();
    		Thread.sleep(1000);
    		
    		System.out.println("测试点击“缺陷诊断”标签");
    		elementFaultDiagnose.click();
    		Thread.sleep(1000);
    	} catch(Exception e) {
    		System.out.println("测试失败");
    		rs = false;
    	}
		driver.quit();
		System.out.println("测试成功");
    	assertTrue(rs);
    }
    
    //状态事件组合-路径2
    public void testNavagtion4() throws InterruptedException {
        boolean rs=true;
     	try {
     		System.out.println("测试：状态事件组合路径2");
			System.out.println("测试打开布尔表达式可视化系统");
			driver = new ChromeDriver();
			driver.get("http://2084w1u146.imwork.net:20890/");
			
     		System.out.println("打开成功");
     		System.out.println("测试点击“层次关系”标签");
	    	WebElement searchButton = driver.findElement(By.className("top"))
	    			.findElement(By.tagName("a"));
	    	searchButton.click(); 
	    	Thread.sleep(1000);
	    	
	    	System.out.println("测试点击“可视化系统”标签");
	    	WebElement searchButton1 = driver.findElement(By.className("top"))
	    			.findElement(By.tagName("a"));
	    	searchButton1.click(); 
	    	Thread.sleep(1000);
     		
     		
			
    	} catch(Exception e) {
    		System.out.println("测试失败");
    		rs = false;
    	}
		driver.quit();
		System.out.println("测试成功");
    	assertTrue(rs);
    }
    
    //状态事件组合-路径3
    public void testNavagtion5() throws InterruptedException {
        boolean rs=true;
     	try {
     		System.out.println("测试：状态事件组合路径3");
			System.out.println("测试打开布尔表达式可视化系统");
			driver = new ChromeDriver();
			driver.get("http://2084w1u146.imwork.net:20890/");
			
     		System.out.println("打开成功");
			WebElement elementTabs = driver.findElement(By.id("tabs"));
    		List<WebElement> tabs = elementTabs.findElements(By.className("r-tab"));
//    		WebElement elementFaultDiagnose= tabs.get(0);
//    		WebElement elementScene = tabs.get(1);
    		WebElement elementConfig = tabs.get(2);

    		System.out.println("测试点击“设置”标签");
    		elementConfig.click();
    		Thread.sleep(1000);
    			    	
     		System.out.println("测试点击“层次关系”标签");
	    	WebElement searchButton = driver.findElement(By.className("top"))
	    			.findElement(By.tagName("a"));
	    	searchButton.click(); 
	    	Thread.sleep(1000);
     		
			
    	} catch(Exception e) {
    		System.out.println("测试失败");
    		rs = false;
    	}
		driver.quit();
		System.out.println("测试成功");
    	assertTrue(rs);
    }
    
  //状态事件组合-路径4
    public void testNavagtion6() throws InterruptedException {
        boolean rs=true;
     	try {
     		System.out.println("测试：状态事件组合路径4");
			System.out.println("测试打开布尔表达式可视化系统");
			driver = new ChromeDriver();
			driver.get("http://2084w1u146.imwork.net:20890/");
			
     		System.out.println("打开成功");
			WebElement elementTabs = driver.findElement(By.id("tabs"));
    		List<WebElement> tabs = elementTabs.findElements(By.className("r-tab"));
    		WebElement elementScene = tabs.get(1);

    		System.out.println("测试点击“场景”标签");
    		elementScene.click();
    		Thread.sleep(1000);
    			    	
     		System.out.println("测试点击“层次关系”标签");
	    	WebElement searchButton = driver.findElement(By.className("top"))
	    			.findElement(By.tagName("a"));
	    	searchButton.click(); 
	    	Thread.sleep(1000);
     		
			
    	} catch(Exception e) {
    		System.out.println("测试失败");
    		rs = false;
    	}
		driver.quit();
		System.out.println("测试成功");
    	assertTrue(rs);
    }
    



}